<?php
    $this->load->view("fungsiPenting.php");
?>
<div class="container" style="margin-top:40px">
	<div class="col-md-offset-1">
	<div class="col-md-11">
	<div class="form-horizontal">
		<div class="panel panel-default">
			<div class="panel-heading">
			<h4 class="panel-title"><b> Report Filter</b></h4>
			</div>
			<div class="panel-body">	
				<div class="row">
					<form method="post" accept-charset="utf-8" />
					<div class="col-sm-12">
						
							<div class="col-sm-3 form-group ">
									<div class="input-group">
										<span class="input-group-addon">From</span>
										<input type="text" class="form-control text-center input-sm" name="date_start" id="datepicker1" value="<?php echo $date_start_set; ?>">
									</div>
								
							</div>
							<div class="col-sm-3 form-group ">
									<div class="input-group">
										<span class="input-group-addon">To</span>
										<input type="text" class="form-control text-center input-sm" name="date_end" id="datepicker2" value="<?php echo $date_end_set; ?>">
									</div>
								
							</div>
							<div class="col-sm-3 form-group ">
								<div class="btn-group">
									
										<button type="submit" class="form-group btn btn-default btn-sm" >Retrieve</button>
									
								</div>
							</div>
							
						
					</div>
					<form>
				</div>
				
			</div>
		</div>
	</div>
	</div>
	</div>
	<?php if($table2 != null) { ?>
	<div class="col-md-offset-1">
	<div class="col-md-11">
	<div id="report" class="panel panel-default">
		<div class="panel-heading">
		<h4 class="panel-title"><b> Space Management</b></h4>
		
		<div class="btn-group pull-right">
			<button class="btn btn-default btn-sm" id="btnExport"><i class="icon-file-excel on-left"></i> Excel</button>
			<button class="btn btn-default btn-sm" type='button' value='Print' onclick="printDiv('tblExport');"><i class="icon-printer on-left"></i> Print</button>
		</div>
		
		</div>
		<div class="panel-body" id="tblExport">	
			<div class="row">
				<div class="col-sm-4">
					<img class="img-responsive" src="<?php echo base_url() ?>static/images/logo_telkomsel.png">
				</div>
				<div class="col-sm-4" align="center">
					PT SANGGARCIPTA KREASITAMA<br />
					MANAGEMENT OFFICE<br />
					JL JEND GATOT SUBROTO NO.42 JAKARTA 12170 - INDONESIA<br />
					TELP: 3000 2008 FAX 3000 2009<br />
				</div>
				<div class="col-sm-4"></div>
			</div>
			<br />
			
			<div class="row">
				<div class="col-sm-12">
					<div class="table-responsive">
						<table class="table">
							<tr>
								<td width="5%" style="background-color:#eee;">Periode</td>
								<td><?php echo tgl_indo($date_start_set)." - ".tgl_indo($date_end_set);?></td>
							</tr>
						</table>
					</div>
					<div class="table-responsive">
						<!--<table class="table" width="100%">--> <!-- JIKA AKTIF, tampilan OK tapi terpotong saat cetak pdf akibat class CSS-->
                        <table>
							<tr>
								<th width="1%" height="25" style="text-align:center;">No.</th>
								<th width="10%" height="25" style="text-align:center;">NIK</th>
								<th width="10%" height="25" style="text-align:center;">Nama</th>
								<th width="10%" height="25" style="text-align:center;">No. Ruang</th>
								<th width="10%" height="25" style="text-align:center;">Fasilitas</th>
                                <th width="10%" height="25" style="text-align:center;">Jabatan</th>
							</tr>
							<?php
								if($table2 != null)
								{
									$i = 0;
									
									foreach($table2 as $data2)
									{
										$i++;
                                        $nik=$data2['REQ_ID'];
                                        $nama=$data2["REQ_UNTUK_NIK"]." - ".$data2['NAME'];
                                        $noruang="?(ROOM BY FLOOR BY RBF_ID)";
                                        $fasilitas="?(ROOM BY FLOOR BY RBF_ID)";
                                        $jabatan=$data2['JOB'];
										?>
                                        <tr>
    										<td align='center'><?php echo $i;?></td>
    										<td align='left'><?php echo $nik;?></td>
    										<td align='left'><?php echo $nama;?></td>
    										<td align='left'><?php echo $noruang;?></td> 
                                            <td align='left'><?php echo $fasilitas;?></td>
                                            <td align='left'><?php echo $jabatan;?></td>
                                            <?php
										?>
                                        </tr><?php
									}
								}
							?>
						</table>
					</div>
					<div class="table-responsive">
						<table class="table">
							<tr bgcolor=#ffffff>
								<td colspan="4" align="left" width="50%">
                                <!--
                                LIST ALL SPARE PARTS &amp; MATERIAL USED ON REVERSE SIDE 
                                -->
                                Jakarta, <?php echo tgl_indo(date('d-m-Y'));?>
                                <br /><br /><br />
                                Manager
                                </td>
                                <td align="left">
                                SPV Building Management
                                <br /><br /><br />
                                Manager    
                                </td>
							</tr>
						</table>
					</div>
				</div>
			</div>
			
		</div>
	</div>
	</div>
	</div>
	<?php } ?>
</div>
</div>

<script>
	$(function() {
		$("input[id^='datepicker']").datetimepicker({
			scrollInput: false,
			yearOffset:0,
			lang:'en',
			timepicker:false,
			datepicker:true,
			format:'d-m-Y',
			formatDate:'d/m/Y',
			/*minDate:'-1970/01/01',
			onGenerate:function( ct ){
				$(this).find('.xdsoft_date.xdsoft_weekend')
					.addClass('xdsoft_disabled');
			}*/
		});
	});
</script>
<script>
    $(document).ready(function () {
        $("#btnExport").click(function () {
            $("#tblExport").btechco_excelexport({
                containerid: "tblExport"
               , datatype: $datatype.Table
               , filename: 'Report_SpaceManagement_<?php echo str_replace("-","",$this->input->post('date_start'))."-".str_replace("-","",$this->input->post('date_end')); ?>'
            });
			
        });
		
    });
</script>
<script>
	function printDiv(divName) 
	{
		var printContents = document.getElementById(divName).innerHTML;     
		var originalContents = document.body.innerHTML;       
		document.body.innerHTML = printContents;      
		window.print();      
		document.body.innerHTML = originalContents;
		window.parent.reload();
   }
</script>
<style type="text/css">
table { border-collapse:collapse; width:100%;}
table td, table th { border:1px solid #ddd; padding:2px; }

table { page-break-inside:auto }
tr    { page-break-inside:avoid; page-break-after:auto }
thead { display:table-header-group }
tfoot { display:table-footer-group }

.table > tbody > tr > td {
	padding: 3px;
}
</style>

